<?php 
	$id = $_GET['id'];
	$username = $_POST['username'];
	$password = $_POST['password']; 
	$type = $_POST['type'];
	
	if( $username != "" && $password != "" && $type != "" ){
		$password = md5($password);
		if( $type == '1'){ 
			$type = 'all'; 
		}else if( $type == '2' ){
			$type = 'part';
		}else{ 
			$type = 'less';
		}
		include '../common/connect.php';
		if( empty($id) ){
			mysql_query("INSERT INTO user (username,password,type) VALUES ( '".$username."','".$password."','".$type."')");
		}else{
			mysql_query("UPDATE user SET username = '".$username."',password = '".$password."',type = '".$type."' WHERE id = '".$id."'");
		}
		mysql_close($con);
		$result = array(
			'status' => 1
		);
	}else{
		$result = array(
			'status' => 0
		);
	}
	echo json_encode($result);
?>